//
//  MPBidObject.m
//  M800Project
//
//  Created by 姚宗超 on 14/11/5.
//  Copyright (c) 2014年 姚宗超. All rights reserved.
//

#import "MPBidObject.h"
#import "NSDictionary+Common.h"

@interface MPBidObject ()
//@property (nonatomic, readwrite, strong)NSNumber* bidId;
//@property (nonatomic, readwrite, copy)NSString* bidName;
//@property (nonatomic, readwrite, copy)NSString* bidPlatformName;
//@property (nonatomic, readwrite, strong)NSNumber* platformBidId; // 平台中标的ID（用于程序间跳转，目前第一P2P的站内ID 其他网站设为空）
//@property (nonatomic, readwrite, strong)NSNumber* yearRate; // 年化收益率
//@property (nonatomic, readwrite, strong)NSNumber* durationId; // 投资期限
//@property (nonatomic, readwrite, strong)NSNumber* bidProgress; // 投资进度
//@property (nonatomic, readwrite, copy)NSString* bidSource; // 标的来源

@end

@implementation MPBidObject
/*
 isMonth = 0;
 listId = 9070432;
 platform = "\U7ea2\U5cad\U521b\U6295";
 productId = "";
 progress = 20;
 repayLimitTime = 30;
 source = "https://www.my089.com/Loan/Detail.aspx?sid=14111016363814291266920015971779";
 title = "\U77ed\U671f\U5468\U8f6c1\U4e2a\U6708_1411101636";
 yearRate = 10;
*/
+ (id)bidWithInfoDic:(NSDictionary *)infoDic
{
    MPBidObject* bid = [[MPBidObject alloc] init];
    bid.bidId = [infoDic objectForKey:@"listId"];
    bid.bidName = [infoDic stringValueForKey:@"title"];
    bid.bidPlatformName = [infoDic stringValueForKey:@"platform"];
    bid.bidIdInFP = [infoDic stringValueForKey:@"productId"];
    bid.yearRate = [NSString stringWithFormat:@"%@%%", [infoDic stringValueForKey:@"yearRate"]];
    BOOL isMonth = [infoDic boolValueForKey:@"isMonth"];
    NSString* duration = [infoDic stringValueForKey:@"repayLimitTime"];
    if (isMonth) {
        bid.duration = [NSString stringWithFormat:@"%@月", duration];
    }
    else
    {
        bid.duration = [NSString stringWithFormat:@"%@天", duration];
    }
    bid.bidProgress = [infoDic floatValueForKey:@"progress"]/100.0f;
    bid.bidSource = [infoDic stringValueForKey:@"source"];
    return bid;
}

@end
